import { createBrowserRouter } from 'react-router-dom'
import App from '../App'

const router = createBrowserRouter([
    {
        path: '/',
        element: <App></App>,
        children: [
            {
                path: '/index',
                lazy: async () => {
                    const { default: Index } = await import('../pages/index/Index');
                    return {
                        element: <Index></Index>
                    }
                }
            },
            {
                path: '/class',
                lazy: async () => {
                    const { default: Class } = await import('../pages/class/Index');
                    return {
                        element: <Class></Class>
                    }
                }
            },
            {
                path: '/user',
                lazy: async () => {
                    const { default: User } = await import('../pages/user/Index');
                    return {
                        element: <User></User>
                    }
                }
            },
            {
                path: '/my',
                lazy: async () => {
                    const { default: My } = await import('../pages/my/Index');
                    return {
                        element: <My></My>
                    }
                }
            }
        ]
    },
    {
        path: '*',
        lazy: async () => {
            const { default: Error } = await import('../pages/error/Index');
            return {
                element: <Error></Error>
            }
        }
    },
    {
        path: '/login',
        lazy: async () => {
            const { default: Login } = await import('../pages/login/Index');
            return {
                element: <Login></Login>
            }
        }
    },
     {
        path: '/search',
        lazy: async () => {
            const { default: Search } = await import('../pages/search/Index');
            return {
                element: <Search></Search>
            }
        }
    },
    {
        path: '/map',
        lazy: async () => {
            const { default: Map } = await import('../pages/map/Index');
            return {
                element: <Map></Map>
            }
        }
    },
    {
        path: '/message',
        lazy: async () => {
            const { default: Message } = await import('../pages/message/Index');
            return {
                element: <Message></Message>
            }
        }
    },
    {
        path: '/list',
        lazy: async () => {
            const { default: List } = await import('../pages/list/Index');
            return {
                element: <List></List>
            }
        }
    },
    {
        path: '/detail',
        lazy: async () => {
            const { default: Detail } = await import('../pages/detail/Index');
            return {
                element: <Detail></Detail>
            }
        }
    },
    {
        path: '/detail1',
        lazy: async () => {
            const { default: Detail1 } = await import('../pages/detail1/Index');
            return {
                element: <Detail1></Detail1>
            }
        }
    },
    {
        path: '/detail2',
        lazy: async () => {
            const { default: Detail2 } = await import('../pages/detail2/Index');
            return {
                element: <Detail2></Detail2>
            }
        }
    },
     {
        path: '/xiaoxi',
        lazy: async () => {
            const { default: Xiaoxi } = await import('../pages/xiaoxi/Index');
            return {
                element: <Xiaoxi></Xiaoxi>
            }
        }
    },
])
export default router